package org.example.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Ran
 * @Date: 2021/9/26
 **/
@Configuration
public class ProxySocksRunner implements ApplicationRunner {

    @Value("${proxy.socks.host}")
    private String host;

    @Value("${proxy.socks.port}")
    private String port;

    public void setProxy() {
        System.setProperty("socksProxyHost", host);
        System.setProperty("socksProxyPort", port);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        setProxy();
    }
}
